//
//  JCMessageListModel.m
//  Victor
//
//  Created by 郭吉成 on 2017/10/18.
//  Copyright © 2017年 coollang. All rights reserved.
//

#import "JCMessageListModel.h"
#import "NSString+Extension.h"

@implementation JCMessageListModel

+ (NSArray<JCMessageListModel *> *)creatMessageListWithDictionnary:(NSDictionary *)sourceDic{
    NSMutableArray *array = [NSMutableArray array];
    NSArray *sourceArray = sourceDic[@"errDesc"];
    
    for (NSDictionary *dic in sourceArray) {
        JCMessageListModel *model = [JCMessageListModel new];
        model.messageID = [NSString checkIfNullWithString:dic[@"ID"]];
        model.messageType = [[NSString checkIfNullWithString:dic[@"Type"]] integerValue];
        model.mainID = [NSString checkIfNullWithString:dic[@"MainID"]];
        model.childID = [NSString checkIfNullWithString:dic[@"ChildID"]];
        model.userID = [NSString checkIfNullWithString:dic[@"UserID"]];
        model.isDelete = [[NSString checkIfNullWithString:dic[@"State"]] boolValue];
        model.creatTime = [NSString checkIfNullWithString:dic[@"CreateTime"]];
        model.imageList = dic[@"ImgList"];
        if (model.imageList == nil || [model.imageList isEqual:[NSNull null]]) {
            model.imageList = @[];
        }
        model.text = [NSString checkIfNullWithString:dic[@"Text"]];
        model.userName = [NSString checkIfNullWithString:dic[@"UserName"]];
        model.icon = [NSString checkIfNullWithString:dic[@"Icon"]];
        [array addObject:model];
    }
    return [array mutableCopy];
}

@end
